package com.th.apicenter.rta;

import com.th.apicenter.rta.service.JDRTAService;
import com.th.apicenter.tools.ThResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/jdrta")
@Slf4j
public class JDRTAController {

    @Autowired
    private JDRTAService jdrtaService;


    @GetMapping("/report")
    public ThResult report() {

        return ThResult.success("成功！");
    }

    /**
     * 接收京东回传
     *
     * @param cbId
     * @param event_type
     * @return
     */
    @GetMapping("/cb")
    public ThResult JDCallback(@RequestParam(name = "cbId", required = false) String cbId,
                                @RequestParam(name = "event_type", required = false) String event_type
    ) {
        jdrtaService.cb(cbId, event_type);
        return ThResult.success("成功！");
    }


}
